/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;


import entity.ViewCart;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
/**
 *
 * @author HP
 */
public class tableViewC extends AbstractTableModel{

    List<ViewCart> list ; 

    public List<ViewCart> getList() {
        return list;
    }

    public void setList(List<ViewCart> list) {
        this.list = list;
    }
    
    public tableViewC()
    {
       // list = new ArrayList<ViewCart>();
    }
    
    public tableViewC(List<ViewCart> list)
    {
        if(list==null)
            this.list = new ArrayList<ViewCart>();
        else
            this.list = list;
    }
    
     public void showList()
    {
        System.out.println("faf");
        System.out.println(list.size());
        for(ViewCart v : list)
        {
            System.out.println("Id Pcard : " + v.getProduct_Id());
        }
    }
    
    @Override
    public int getRowCount() {
        return  list.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex)
        {
            case 0:
                return list.get(rowIndex).getProduct_Id()+"";
            case 1:
                return list.get(rowIndex).getProduct_Name();
            case 2:
                return list.get(rowIndex).getProduct_Quantity()+"";
            case 3:
                return list.get(rowIndex).getProduct_Price()+"";
            case 4:
                return list.get(rowIndex).getTotal()+"";
            default:
                return null;
        }
    }
    
    @Override
    public String getColumnName(int col)
    {
        switch(col)
        {
            case 0:
                return "Product_Id";
            case 1:
                return "Product_Name";
            case 2:
                return "Product_Quantity";
            case 3:
                return "Product_Price";
            case 4:
                return "Total";
            default:
                return null;
        }
    }
    // @Override
//    public Class<?> getColumnClass(int column)
//    {
//   //     return this.getValueAt(0, column).getClass();
//    }
}
